//
//  SNKNewsPageController.m
//  SleepNews
//
//  Created by Kavee DJ on 2017/1/9.
//  Copyright © 2017年 Kavee DJ. All rights reserved.
//

#import "SNKNewsPageController.h"
#import "SNKHeadNewsController.h"
#import "SNKOtherNewsController.h"
#import "SNKPrettyGirlController.h"

#import "UIBarButtonItem+SNK.h"

#import <RESideMenu.h>

@interface SNKNewsPageController ()

@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, strong) NSMutableArray *vcArray;

@end

@implementation SNKNewsPageController

#pragma mark - Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.title = @"新闻";
    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem ItemWithIcon:@"leftlive_icon" highIcon:nil target:self action:@selector(live)];
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem ItemWithIcon:@"nav_searchIcon" highIcon:nil target:self action:@selector(searchClick)];

}

#pragma mark - Private Method
-(void)live
{
    [self.sideMenuViewController presentLeftMenuViewController];
}

-(void)searchClick
{
    [self.sideMenuViewController presentRightMenuViewController];
}


#pragma mark - WMPageController DataSource
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.titleArray.count;
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    return self.vcArray[index];
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.titleArray[index];
}

#pragma mark - Getter and Setter
- (NSArray *)titleArray {
    if (!_titleArray) {
        _titleArray = @[@"头条",@"美图",@"新闻",@"财经",@"体育",@"娱乐",@"军事",@"教育",@"科技",@"NBA",@"股票",@"星座",@"家庭",@"健康",@"育儿"];
    }
    return _titleArray;
}

- (NSMutableArray *)vcArray {
    if (!_vcArray) {
        _vcArray = [NSMutableArray array];
        // 前两个单独设置 "头条"
        NSArray *nameArray = @[@"新闻",@"财经",@"体育",@"娱乐",@"军事",@"教育",@"科技",@"NBA",@"股票",@"星座",@"女性",@"健康",@"育儿"];
        
        SNKHeadNewsController *oneViewController = [[SNKHeadNewsController alloc] init];
        oneViewController.title = @"头条";
        [_vcArray addObject:oneViewController];
        
        // 加一个美女
        SNKPrettyGirlController *prettyGirlVC = [[SNKPrettyGirlController alloc] init];
        [_vcArray addObject:prettyGirlVC];
        
        for (NSInteger i = 0; i < nameArray.count; i++) {
            SNKOtherNewsController *otherViewController = [[SNKOtherNewsController alloc] init];
            otherViewController.title = nameArray[i];
            otherViewController.content = nameArray[i];
            [_vcArray addObject:otherViewController];
        }
        
    }
    return _vcArray;
}

@end
